{extend name="admin@common/main"/}
{block name="body"}
    <div class="main-title">
        <h2>{:lang('_PACK_STEP_FOUR_')}
            <small>{:lang('_PACK_STEP_FOUR_VICE_')}</small>
        </h2>
    </div>

    <div class="with-padding">
        <div class="clearfix">
            <div class="alert alert-info">
                {:lang('_PACK_MODULE_NOW_')}{:lang('_COMMA_')}<strong>{$module.alias}-{$module.name}</strong>
            </div>
        </div>
        <form id="form_main" action="{:url('module5')}" method="post">
            <div class="clearfix">

                <p class="lead">{:lang('_PACK_ASSOCIATED_TABLE_')}</p>
                {empty name="tables" value=""}
                <div class="alert alert-success">
                    {:lang('_PACK_DETECTED_TABLE_NONE_SKIP_')}
                </div>
                {else/}
                <div class="col-xs-5">
                    <blockquote>
                        {volist name="tables" id="vo"}
                            <p><label> <span class="text-primary">【{$i}】{$vo.name} </span>&nbsp;（{$vo.rows}） {$vo.comment}</label>
                            </p>
                        {/volist}
                    </blockquote>
                </div>
                <div class="col-xs-4">
                    <p class="lead">{:lang('_PACK_SCRIPT_PREVIEW_')}</p>
                    <textarea name="sql_tables" class="form-control" style="height: 200px">{$sql_tables|htmlspecialchars}</textarea>
                </div>
                {/empty}
            </div>

            <div class="clearfix">
                <p class="lead">{:lang('_PACK_DATA_INPUT_DEFAULT_')}</p>

                <p>{:lang('_PACK_CHECK_FOR_PACK_UP_')}</p>
                {notempty name="has_data" value=""}
                    <div class="col-xs-5">

                        <blockquote>
                            {volist name="has_data" id="vo"}
                                <p><label><input name="tables[]" data-role="check_table" type="checkbox" checked value="{$vo.name}">
                                    <span class="text-primary">【{$i}】{$vo.name} </span> &nbsp;（{$vo.rows}）</label></p>
                            {/volist}
                        </blockquote>

                    </div>
                    <div class="col-xs-4">
                        <p class="lead">{:lang('_PACK_SCRIPT_PREVIEW_')}</p>
                        <textarea name="sql_rows" class="form-control" style="height: 200px">{$sql_rows|htmlspecialchars}</textarea>
                    </div>
                {else/}
                    <div class="alert alert-success">{:lang('_PACK_DETECTED_TABLE_DATA__NONE_SKIP_')}</div>
                {/notempty}
                <script>
                    $(function () {
                        $('[data-role=check_table]').change(function () {
                            $.post(U('Admin/Devtool/backup_rows'),$('#form_main').serialize(),function(msg){
                                $('[name=sql_rows]').val(msg)
                            })
                        })
                    })
                </script>

            </div>
            <div class="clearfix">
                <p class="lead">{:lang('_PACK_DATA_CLEAR_SQL_')}</p>


                {neq name="has_data" value=""}
                    <div class="col-xs-5">
                        <p>{:lang('_PACK_DATA_CLEAR_SQL_OPTIONS_')}</p>
                    </div>
                    <div class="col-xs-4"> <textarea name="sql_drop_table" class="form-control" style="height: 200px">{$sql_drop_tables}</textarea></div>
                {else/}
                    <div class="alert alert-success">{:lang('_PACK_DETECTED_TABLE_DATA__NONE_SKIP_')}</div>
                {/neq}
                <script>
                    $(function () {
                        $('[data-role=check_table]').change(function () {
                            $.post(U('Admin/Devtool/backup_rows'),$('#form_main').serialize(),function(msg){
                                $('[name=sql_rows]').val(msg)
                            })
                        })
                    })
                </script>
            </div>
            <div class="clearfix" style="margin-top:10px;">
                <a class="btn btn-lg btn-default" href="{:url('module3')}">
                    {:lang('_STEP_PREV_')}
                </a>
                <a class="btn btn-lg btn-default" href="{:url('module4')}">
                    <i class="icon-refresh"></i> {:lang('_DETECT_RE_')}
                </a>
                

                <button type="submit" id="next_step" style="width: 300px" class="btn btn-lg btn-success">
                       {:lang('_STEP_NEXT_')}
                </button>
            </div>
        </form>
    </div>
{/block}